package com.mq.broadcast;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author ytj
 * @date 2024/1/17
 */
@Component
@RabbitListener(
        bindings = @QueueBinding(
                value = @Queue(
                        value = BroadcastMessage.QUEUE+"-"+"#{T(java.util.UUID).randomUUID()}",
                        autoDelete = "true"
                ),
                exchange = @Exchange(
                        name = BroadcastMessage.EXCHANGE,
                        type = ExchangeTypes.TOPIC,
                        declare = "false"
                )
        )
)
public class BroadcastConsumer1 {

    @RabbitHandler
    public void message(BroadcastMessage message){
        System.out.println("消费者2：线程号:"+Thread.currentThread().getId()+",消息内容:"+message.getId());
    }
}
